After completing this lesson, you’ll be able to:
There are two types of custom transformers.
Workspaces store the definition of embedded transformers in the workspace itself. Each instance of the custom transformer refers to that embedded definition. Only the workspace with the embedded transformer has access to that custom transformer.
A linked transformer has its definition stored outside the workspace in a separate file. Each instance of a linked transformer relies on that external definition. Any workspace can have access to that custom transformer.
On a workspace canvas, embedded transformers are identified by their green color, while linked transformers are colored cyan:
You can use both types of transformers in an FME workspace, and there are various advantages and disadvantages to each type.
Embedded Transformers
Embedded transformers are easier to manage, need no external files, and store their definition directly in the workspace. They are handy for tidying a workspace and employing advanced functionality like parallel processing.
However, sharing and re-using content is not straightforward with an embedded transformer. You cannot easily share the custom transformer with other users unless you give them a copy of the same workspace. Additionally, it is not easy to maintain a consistent definition among several users.
Linked Transformers
Linked transformers are perhaps a little harder to manage. They exist as a file (.fmx) outside of the workspace, which is less convenient, and when used to employ advanced functionality such as loops, they can be more complex.
However, a linked custom transformer is a little easier to edit (you open the .fmx file rather than the .fmw file) and is much easier to share among users. Not only can the file be given to any FME author to use, but any number of authors can point their workspace to the same custom transformer file.
Sharing the same file is useful because any changes made to the definition automatically propagate to all workspaces that use it.
Like embedded transformers, linked transformers also show up in the transformer gallery and Quick Add dialog. Also, notice that they have a special icon to signify that you are about to use a linked version rather than the embedded version:
All custom transformers start with an embedded definition. To create an external definition, export the custom transformer using the Export as Custom Transformer option on the menu bar:
At this point, a dialog opens in which you can confirm the transformer name and category, plus some other parameters, including the save location:
Name and category are straightforward, so let’s look at some of the other options.
Insert Mode
We know that the definition of a custom transformer can be stored either in a workspace (embedded) or in a separate file (linked). Therefore each instance of a custom transformer points to either an embedded or linked definition.
But it’s important to know that each instance can change its definition source. For example, you can switch an instance of a custom transformer linked to a file definition to embedded (in which case the external definition gets embedded into the workspace).
Likewise, you can switch an instance that points to an embedded definition to point to an external file.
As the author of a custom transformer, I might want to control the initial state when I first place an instance. The Insert Mode parameter controls this behavior.
There are four different modes:
Let’s say I export my custom transformer with Insert Mode set to one of the Embedded choices. An FMX file now stores the definition, and FME will recognize it as an available transformer. But when a user places a new instance in their workspace (say with Quick Add or the Transformer Gallery), the definition of the custom transformer is copied from the FMX file and embedded into the workspace.
If I choose Embedded By Default, although each transformer instance starts as Embedded, the user can switch the instance to “Linked” at any point.
If I choose Embedded Always, each transformer instance starts as embedded and must stay that way. A user cannot switch it to Linked at a later point.
Similarly, I could export my custom transformer in Linked mode. When a user places a new instance, the definition of the transformer remains in my FMX file, with the instance linked to it.
If I choose Linked By Default, each instance of the transformer starts as Linked but can be switched to Embedded at any time.
If I choose Linked Always, each instance starts as Linked and stays that way. To cannot be switched to Embedded at a later point.
Which Mode to Use
Embedded Always is a good choice when the person using the transformer is less experienced with FME; it’s easier for them to manage, and if they make changes, they won’t affect other people. Embedded is also a good choice when you intend for individuals to use the custom transformer (i.e., not sharing it as a group).
Linked Always is a good choice when you intend for a group of users to share the custom transformer. Because it is linked, the users will always receive updates if the transformer definition is changed, and because the definition is shared, it becomes a standard applied to all users.
Only when the end-user is experienced in FME and can understand the consequences is it advisable to use a “By Default” setting and allow type switching.
Password
The password field allows you to password-protect the custom transformer. This setting makes it impervious to edits from unauthorized persons. Additionally, the file contents are (very mildly) encrypted, so unauthorized users cannot copy them by opening the source file in a text editor.
This setting allows authors to make transformers available for purchase without fear that their work will be copied or edited. Of course, it’s essential not to forget or lose the password yourself if you wish to make edits!
Save Location
FME has a specific installation folder where it saves custom transformer files. If you save custom transformers in this folder, you can find them in Workbench and use them the same as any other transformers. If you save transformers elsewhere, you won’t be able to find them in Workbench unless you add the path under Tools > FME Options > Default Paths.
Editing a Linked Custom Transformer
When you click the OK button on the Export as Custom Transformer dialog, FME exports the transformer to a separate (.fmx) file. That file is immediately opened inside a new instance of FME Workbench for you to make edits.
In essence, editing a custom transformer works the same way as editing a workspace: you open the file in FME Workbench and make edits as required.
The critical part to remember is that any changes you make will affect each instance of the Custom Transformer linked to this file.
When the Insert Mode of a custom transformer allows type switching, the action is very straightforward. Right-click on the instance and choose the required type:
In the above screenshot, the user is switching from Embedded to Linked. Of course, switching to Linked requires the custom transformer to be exported already.
When you switch from embedded to linked, the embedded definition is closed. The transformer instance then points to the linked definition.
When you switch from linked to embedded, the contents of the FMX file are copied and embedded in the workspace. The transformer instance then points to the embedded definition.
If there is more than one instance of the Custom Transformer, FME asks whether you want to switch all of them:
The usual answer is yes because having the same transformer both embedded and linked could be pretty confusing! If you answer no, then be aware that the transformer you clicked on will be linked (but none of the other instances will).